﻿package  
{
	
	/**
	 * ...利用包外类限制生成单例类的实例
	 * @author chancidal
	 */
	public class AnotherSingle 
	{
		//
		private static var m_instance:AnotherSingle;
		//
		public function AnotherSingle(singletonEnforcer:MyEnforcer) 
		{
			if (!singletonEnforcer) {
				throw new Error("Singleton and can only be accessed through Singleton.getInstance()");
			}
		}
		public static function getInstance():AnotherSingle {
			if (!m_instance) {
				m_instance = new AnotherSingle(new MyEnforcer())
			}
			return m_instance;
		}
		public function sayHello():void {
			trace("hello,world");
		}
	}
	
}
class MyEnforcer {
	
}